import os


class Config:
    # 数据库配置
    DATABASE_PATH = os.getenv('DATABASE_PATH', 'exam_management.db')

    # Flask配置
    SECRET_KEY = os.getenv('SECRET_KEY', 'dev-secret-key-change-in-production')
    DEBUG = os.getenv('FLASK_DEBUG', 'True').lower() == 'true'

    # 查重配置
    SIMILARITY_THRESHOLD = float(os.getenv('SIMILARITY_THRESHOLD', '0.8'))

    # 文件上传配置
    UPLOAD_FOLDER = os.getenv('UPLOAD_FOLDER', 'uploads')
    MAX_CONTENT_LENGTH = 16 * 1024 * 1024  # 16MB

    # 安全配置
    SESSION_TIMEOUT = int(os.getenv('SESSION_TIMEOUT', '3600'))  # 1小时

    # 分页配置
    QUESTIONS_PER_PAGE = int(os.getenv('QUESTIONS_PER_PAGE', '20'))
    PAPERS_PER_PAGE = int(os.getenv('PAPERS_PER_PAGE', '10'))

    # 新增：相似度检查配置
    SIMILARITY_THRESHOLD = float(os.getenv('SIMILARITY_THRESHOLD', '0.8'))
    SIMILARITY_ALGORITHMS = ['jaccard', 'edit_distance', 'tfidf']

    # 新增：难度分析配置
    DIFFICULTY_AUTO_ADJUST = os.getenv('DIFFICULTY_AUTO_ADJUST', 'True').lower() == 'true'
    DIFFICULTY_CONFIDENCE_THRESHOLD = float(os.getenv('DIFFICULTY_CONFIDENCE_THRESHOLD', '0.7'))

    # 新增：考察记录配置
    EXAM_RECORD_RETENTION_DAYS = int(os.getenv('EXAM_RECORD_RETENTION_DAYS', '365'))

    # 新增：统计分析配置
    STATISTICS_CACHE_HOURS = int(os.getenv('STATISTICS_CACHE_HOURS', '24'))
    ENABLE_ADVANCED_ANALYTICS = os.getenv('ENABLE_ADVANCED_ANALYTICS', 'True').lower() == 'true'


# requirements.txt 内容
"""
Flask==2.3.3
Flask-CORS==4.0.0
sqlite3
difflib
python-docx==0.8.11
openpyxl==3.1.2
reportlab==4.0.4
"""

# run.py - 启动脚本
"""
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import os
import sys
from app import app
from config import Config

if __name__ == '__main__':
    # 设置配置
    app.config.from_object(Config)

    # 创建必要的目录
    os.makedirs(Config.UPLOAD_FOLDER, exist_ok=True)

    print("=" * 50)
    print("试题管理系统")
    print("=" * 50)
    print(f"数据库路径: {Config.DATABASE_PATH}")
    print(f"上传文件夹: {Config.UPLOAD_FOLDER}")
    print(f"相似度阈值: {Config.SIMILARITY_THRESHOLD}")
    print("=" * 50)
    print("系统启动中...")

    app.run(
        debug=Config.DEBUG,
        host='0.0.0.0',
        port=5000
    )
"""